clear 

** read in .dta file **

use "${clean}/who_counts_analysis.dta", clear

** Coefficent Plots, Speficiations without interactions, 1945-1955 and 1945-1962 **

** regressions **

xi: reghdfe MOB did_ANY Arabic Female, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW2_simple_any

xi: reghdfe MOB did_ANY Arabic Female *_itTREATED *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW2_any

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW2_simple_any

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW2_any

xi: reghdfe French_Lit did_edu_ANY Arabic Female, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW2_simple_any

xi: reghdfe French_Lit did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW2_any

xi: reghdfe Schooling did_edu_ANY Arabic Female, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW2_simple_any

xi: reghdfe Schooling did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW2_any


drop if YOB > 1955


xi: reghdfe MOB did_ANY Arabic Female, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW1_simple_any

xi: reghdfe MOB did_ANY Arabic Female *_itTREATED *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_MOB_did_BW1_any
estimates store m_MOB_did_BW1_any

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW1_simple_any

xi: reghdfe EDU_YRS did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_YRS_did_BW1_any

xi: reghdfe French_Lit did_edu_ANY Arabic Female, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW1_simple_any

xi: reghdfe French_Lit did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_LIT_did_BW1_any

xi: reghdfe Schooling did_edu_ANY Arabic Female, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW1_simple_any

xi: reghdfe Schooling did_edu_ANY Arabic Female *_itTREATEDEDU *_itANYFOR, a(geo2_ma reg_fe YOB) cluster(geo2_ma)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_School_did_BW1_any

** output figure ** 

* Add alternative forms of DiD

coefplot (m_MOB_did_BW1_any, label(1945-1955)) (m_MOB_did_BW1_simple_any, label(1945-1955, No Interactions)) (m_MOB_did_BW2_any, label(1945-1962)) (m_MOB_did_BW2_simple_any, label(1945-1962, No Interactions)), keep(did_ANY) vertical yline(0) title("Registration") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/MOB_interact.gph", replace

coefplot (m_School_did_BW1_any, label(1945-1955)) (m_School_did_BW1_simple_any, label(1945-1955, No Interactions)) (m_School_did_BW2_any, label(1945-1962)) (m_School_did_BW2_simple_any, label(1945-1962, No Interactions)), keep(did_edu_ANY) vertical yline(0) title("Formal Schooling") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/School_interact.gph", replace

coefplot (m_YRS_did_BW1_any, label(1945-1955)) (m_YRS_did_BW1_simple_any, label(1945-1955, No Interactions)) (m_YRS_did_BW2_any, label(1945-1962)) (m_YRS_did_BW2_simple_any, label(1945-1962, No Interactions)), keep(did_edu_ANY) vertical yline(0) title("Formal Schooling, Years") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/YRS_interact.gph", replace

coefplot (m_LIT_did_BW1_any, label(1945-1955)) (m_LIT_did_BW1_simple_any, label(1945-1955, No Interactions)) (m_LIT_did_BW2_any, label(1945-1962)) (m_LIT_did_BW2_simple_any, label(1945-1962, No Interactions)), keep(did_edu_ANY) vertical yline(0) title("Literacy, French and Arabic") legend(symys(*.5) symxs(*.5) size(3) pos(6) col(2) bm(tiny)subtitle("Legend"))
graph save Graph "${output}/graphs/LIT_interact.gph", replace

grc1leg  "${output}/graphs/MOB_interact.gph" "${output}/graphs/School_interact.gph" "${output}/graphs/YRS_interact.gph" "${output}/graphs/LIT_interact.gph",legendfrom("${output}/graphs/LIT_interact.gph")
graph save Graph "${output}/graphs/DiD_interact_ALL.gph", replace
graph export "${output}/graphs/Figure9A.png", replace
